/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author grillo
 */
@Entity
@Table(name = "esame")
@NamedQueries({@NamedQuery(name = "Esame.findAll", query = "SELECT e FROM Esame e"), @NamedQuery(name = "Esame.findByIdesame", query = "SELECT e FROM Esame e WHERE e.idesame = :idesame"), @NamedQuery(name = "Esame.findByNome", query = "SELECT e FROM Esame e WHERE e.nome = :nome"), @NamedQuery(name = "Esame.findByDescrizione", query = "SELECT e FROM Esame e WHERE e.descrizione = :descrizione"), @NamedQuery(name = "Esame.findByCrediti", query = "SELECT e FROM Esame e WHERE e.crediti = :crediti")})
public class Esame implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idesame")
    private Integer idesame;
    @Basic(optional = false)
    @Column(name = "nome")
    private String nome;
    @Basic(optional = false)
    @Column(name = "descrizione")
    private String descrizione;
    @Basic(optional = false)
    @Column(name = "crediti")
    private int crediti;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "esame")
    private List<PianoStudio> pianoStudioCollection;
    @JoinColumn(name = "idcorso", referencedColumnName = "idcorso")
    @ManyToOne(optional = false)
    private CorsoStudio idcorso;
    @JoinColumn(name = "matricola_docente", referencedColumnName = "matricola")
    @ManyToOne
    private Docente matricolaDocente;

    public Esame() {
    }

    public Esame(Integer idesame) {
        this.idesame = idesame;
    }

    public Esame(Integer idesame, String nome, String descrizione, int crediti) {
        this.idesame = idesame;
        this.nome = nome;
        this.descrizione = descrizione;
        this.crediti = crediti;
    }

    public Integer getIdesame() {
        return idesame;
    }

    public void setIdesame(Integer idesame) {
        this.idesame = idesame;
    }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }

    public String getDescrizione() {
        return descrizione;
    }

    public void setDescrizione(String descrizione) {
        this.descrizione = descrizione;
    }

    public int getCrediti() {
        return crediti;
    }

    public void setCrediti(int crediti) {
        this.crediti = crediti;
    }

    public List<PianoStudio> getPianoStudioCollection() {
        return pianoStudioCollection;
    }

    public void setPianoStudioCollection(List<PianoStudio> pianoStudioCollection) {
        this.pianoStudioCollection = pianoStudioCollection;
    }

    public CorsoStudio getIdcorso() {
        return idcorso;
    }

    public void setIdcorso(CorsoStudio idcorso) {
        this.idcorso = idcorso;
    }

    public Docente getMatricolaDocente() {
        return matricolaDocente;
    }

    public void setMatricolaDocente(Docente matricolaDocente) {
        this.matricolaDocente = matricolaDocente;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idesame != null ? idesame.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Esame)) {
            return false;
        }
        Esame other = (Esame) object;
        if ((this.idesame == null && other.idesame != null) || (this.idesame != null && !this.idesame.equals(other.idesame))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.Esame[idesame=" + idesame + "]";
    }

}
